//
//  UIBarButtonItem+Extension.swift
//  Practice
//
//  Created by miaozhihui on 2017/1/10.
//  Copyright © 2017年 DeKuTree. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    /// 创建 UIBarButtonItem
    ///
    /// - Parameters:
    ///   - title: title
    ///   - fontSize: fontSize
    ///   - target: target
    ///   - action: action
    ///   - isBack: 是否是返回按钮
    convenience init(title:String,fontSize:CGFloat = 16,target:Any?,action:Selector,isBack:Bool = false) {
        let btn:UIButton = UIButton.xs_textButton(title, fontSize: fontSize, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        if isBack {
            let imageName = "navigationbar_back_withtext"
            btn.setImage(UIImage(named: imageName), for: .normal)
            btn.setImage(UIImage(named: imageName+"_highlighted"), for: .highlighted)
            btn.sizeToFit()
        }
        btn.addTarget(target, action: action, for: .touchUpInside)
        self.init(customView: btn)
    }
}
